package com.coollang.smartbra.activity;

import android.view.View;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.andexert.library.RippleView;
import com.coollang.smartbra.MyAutoLayoutActivity;
import com.coollang.smartbra.R;
import com.coollang.smartbra.utils.TranslucentSystemBarUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @Auther: Timmy
 * @Data: 2017/9/1
 * @Fuction:
 */

public class WebViewActivity extends MyAutoLayoutActivity  {

    @BindView(R.id.status_bar)
    View mStatusBar;
    @BindView(R.id.content)
    LinearLayout mContent;
    @BindView(R.id.tv_title)
    TextView mTvTitle;
    @BindView(R.id.iv_back)
    ImageView mIvBack;
    @BindView(R.id.webview)
    WebView mWebView;

    private Toast mToast;

    @Override
    protected void initView() {
        setContentView(R.layout.activity_webview);
        ButterKnife.bind(this);
        TranslucentSystemBarUtils.showChenJinZhuangTaiLan(mStatusBar, this, mContent);

        initViews();
    }

    private void initViews() {

        mToast = Toast.makeText(this, "", Toast.LENGTH_SHORT);

        int type = getIntent().getIntExtra("web_type", 0);
        mIvBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        switch (type) {
            case 0:
                mToast.setText("加载出错");
                mToast.show();
                break;
            case 1:
                mTvTitle.setText(getString(R.string.service_regulations));
                mWebView.loadUrl("file:///android_asset/service_regulations.html");
                break;
            case 2:
                mTvTitle.setText(getString(R.string.privacy_policy));
                mWebView.loadUrl("file:///android_asset/privacy_policy.html");
                break;
        }

        mTvTitle.setTextColor(getResources().getColor(R.color.black_666));

    }
}
